/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package UISUTModel.impl;

import UISUTModel.Action;
import UISUTModel.UICondition;
import UISUTModel.UISUTModelPackage;
import UISUTModel.UIState;
import UISUTModel.UITransition;
import UISUTModel.UITrigger;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>UI Transition</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link UISUTModel.impl.UITransitionImpl#getItsTrgtState <em>Its Trgt State</em>}</li>
 *   <li>{@link UISUTModel.impl.UITransitionImpl#getItsSrcState <em>Its Src State</em>}</li>
 *   <li>{@link UISUTModel.impl.UITransitionImpl#getItsTrigger <em>Its Trigger</em>}</li>
 *   <li>{@link UISUTModel.impl.UITransitionImpl#getItsCondition <em>Its Condition</em>}</li>
 *   <li>{@link UISUTModel.impl.UITransitionImpl#getItsAction <em>Its Action</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class UITransitionImpl extends UISUTElementImpl implements UITransition {
	/**
	 * The cached value of the '{@link #getItsTrgtState() <em>Its Trgt State</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getItsTrgtState()
	 * @generated
	 * @ordered
	 */
	protected UIState itsTrgtState;

	/**
	 * The cached value of the '{@link #getItsSrcState() <em>Its Src State</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getItsSrcState()
	 * @generated
	 * @ordered
	 */
	protected UIState itsSrcState;

	/**
	 * The cached value of the '{@link #getItsTrigger() <em>Its Trigger</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getItsTrigger()
	 * @generated
	 * @ordered
	 */
	protected UITrigger itsTrigger;

	/**
	 * The cached value of the '{@link #getItsCondition() <em>Its Condition</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getItsCondition()
	 * @generated
	 * @ordered
	 */
	protected UICondition itsCondition;

	/**
	 * The cached value of the '{@link #getItsAction() <em>Its Action</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getItsAction()
	 * @generated
	 * @ordered
	 */
	protected Action itsAction;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected UITransitionImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return UISUTModelPackage.Literals.UI_TRANSITION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public UIState getItsTrgtState() {
		if (itsTrgtState != null && itsTrgtState.eIsProxy()) {
			InternalEObject oldItsTrgtState = (InternalEObject)itsTrgtState;
			itsTrgtState = (UIState)eResolveProxy(oldItsTrgtState);
			if (itsTrgtState != oldItsTrgtState) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, UISUTModelPackage.UI_TRANSITION__ITS_TRGT_STATE, oldItsTrgtState, itsTrgtState));
			}
		}
		return itsTrgtState;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public UIState basicGetItsTrgtState() {
		return itsTrgtState;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetItsTrgtState(UIState newItsTrgtState, NotificationChain msgs) {
		UIState oldItsTrgtState = itsTrgtState;
		itsTrgtState = newItsTrgtState;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, UISUTModelPackage.UI_TRANSITION__ITS_TRGT_STATE, oldItsTrgtState, newItsTrgtState);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setItsTrgtState(UIState newItsTrgtState) {
		if (newItsTrgtState != itsTrgtState) {
			NotificationChain msgs = null;
			if (itsTrgtState != null)
				msgs = ((InternalEObject)itsTrgtState).eInverseRemove(this, UISUTModelPackage.UI_STATE__ITS_IN_TRANSITION, UIState.class, msgs);
			if (newItsTrgtState != null)
				msgs = ((InternalEObject)newItsTrgtState).eInverseAdd(this, UISUTModelPackage.UI_STATE__ITS_IN_TRANSITION, UIState.class, msgs);
			msgs = basicSetItsTrgtState(newItsTrgtState, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, UISUTModelPackage.UI_TRANSITION__ITS_TRGT_STATE, newItsTrgtState, newItsTrgtState));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public UIState getItsSrcState() {
		if (itsSrcState != null && itsSrcState.eIsProxy()) {
			InternalEObject oldItsSrcState = (InternalEObject)itsSrcState;
			itsSrcState = (UIState)eResolveProxy(oldItsSrcState);
			if (itsSrcState != oldItsSrcState) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, UISUTModelPackage.UI_TRANSITION__ITS_SRC_STATE, oldItsSrcState, itsSrcState));
			}
		}
		return itsSrcState;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public UIState basicGetItsSrcState() {
		return itsSrcState;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetItsSrcState(UIState newItsSrcState, NotificationChain msgs) {
		UIState oldItsSrcState = itsSrcState;
		itsSrcState = newItsSrcState;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, UISUTModelPackage.UI_TRANSITION__ITS_SRC_STATE, oldItsSrcState, newItsSrcState);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setItsSrcState(UIState newItsSrcState) {
		if (newItsSrcState != itsSrcState) {
			NotificationChain msgs = null;
			if (itsSrcState != null)
				msgs = ((InternalEObject)itsSrcState).eInverseRemove(this, UISUTModelPackage.UI_STATE__ITS_OUT_TRANSITION, UIState.class, msgs);
			if (newItsSrcState != null)
				msgs = ((InternalEObject)newItsSrcState).eInverseAdd(this, UISUTModelPackage.UI_STATE__ITS_OUT_TRANSITION, UIState.class, msgs);
			msgs = basicSetItsSrcState(newItsSrcState, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, UISUTModelPackage.UI_TRANSITION__ITS_SRC_STATE, newItsSrcState, newItsSrcState));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public UITrigger getItsTrigger() {
		return itsTrigger;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetItsTrigger(UITrigger newItsTrigger, NotificationChain msgs) {
		UITrigger oldItsTrigger = itsTrigger;
		itsTrigger = newItsTrigger;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, UISUTModelPackage.UI_TRANSITION__ITS_TRIGGER, oldItsTrigger, newItsTrigger);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setItsTrigger(UITrigger newItsTrigger) {
		if (newItsTrigger != itsTrigger) {
			NotificationChain msgs = null;
			if (itsTrigger != null)
				msgs = ((InternalEObject)itsTrigger).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - UISUTModelPackage.UI_TRANSITION__ITS_TRIGGER, null, msgs);
			if (newItsTrigger != null)
				msgs = ((InternalEObject)newItsTrigger).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - UISUTModelPackage.UI_TRANSITION__ITS_TRIGGER, null, msgs);
			msgs = basicSetItsTrigger(newItsTrigger, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, UISUTModelPackage.UI_TRANSITION__ITS_TRIGGER, newItsTrigger, newItsTrigger));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public UICondition getItsCondition() {
		return itsCondition;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetItsCondition(UICondition newItsCondition, NotificationChain msgs) {
		UICondition oldItsCondition = itsCondition;
		itsCondition = newItsCondition;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, UISUTModelPackage.UI_TRANSITION__ITS_CONDITION, oldItsCondition, newItsCondition);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setItsCondition(UICondition newItsCondition) {
		if (newItsCondition != itsCondition) {
			NotificationChain msgs = null;
			if (itsCondition != null)
				msgs = ((InternalEObject)itsCondition).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - UISUTModelPackage.UI_TRANSITION__ITS_CONDITION, null, msgs);
			if (newItsCondition != null)
				msgs = ((InternalEObject)newItsCondition).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - UISUTModelPackage.UI_TRANSITION__ITS_CONDITION, null, msgs);
			msgs = basicSetItsCondition(newItsCondition, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, UISUTModelPackage.UI_TRANSITION__ITS_CONDITION, newItsCondition, newItsCondition));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Action getItsAction() {
		return itsAction;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetItsAction(Action newItsAction, NotificationChain msgs) {
		Action oldItsAction = itsAction;
		itsAction = newItsAction;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, UISUTModelPackage.UI_TRANSITION__ITS_ACTION, oldItsAction, newItsAction);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setItsAction(Action newItsAction) {
		if (newItsAction != itsAction) {
			NotificationChain msgs = null;
			if (itsAction != null)
				msgs = ((InternalEObject)itsAction).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - UISUTModelPackage.UI_TRANSITION__ITS_ACTION, null, msgs);
			if (newItsAction != null)
				msgs = ((InternalEObject)newItsAction).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - UISUTModelPackage.UI_TRANSITION__ITS_ACTION, null, msgs);
			msgs = basicSetItsAction(newItsAction, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, UISUTModelPackage.UI_TRANSITION__ITS_ACTION, newItsAction, newItsAction));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case UISUTModelPackage.UI_TRANSITION__ITS_TRGT_STATE:
				if (itsTrgtState != null)
					msgs = ((InternalEObject)itsTrgtState).eInverseRemove(this, UISUTModelPackage.UI_STATE__ITS_IN_TRANSITION, UIState.class, msgs);
				return basicSetItsTrgtState((UIState)otherEnd, msgs);
			case UISUTModelPackage.UI_TRANSITION__ITS_SRC_STATE:
				if (itsSrcState != null)
					msgs = ((InternalEObject)itsSrcState).eInverseRemove(this, UISUTModelPackage.UI_STATE__ITS_OUT_TRANSITION, UIState.class, msgs);
				return basicSetItsSrcState((UIState)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case UISUTModelPackage.UI_TRANSITION__ITS_TRGT_STATE:
				return basicSetItsTrgtState(null, msgs);
			case UISUTModelPackage.UI_TRANSITION__ITS_SRC_STATE:
				return basicSetItsSrcState(null, msgs);
			case UISUTModelPackage.UI_TRANSITION__ITS_TRIGGER:
				return basicSetItsTrigger(null, msgs);
			case UISUTModelPackage.UI_TRANSITION__ITS_CONDITION:
				return basicSetItsCondition(null, msgs);
			case UISUTModelPackage.UI_TRANSITION__ITS_ACTION:
				return basicSetItsAction(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case UISUTModelPackage.UI_TRANSITION__ITS_TRGT_STATE:
				if (resolve) return getItsTrgtState();
				return basicGetItsTrgtState();
			case UISUTModelPackage.UI_TRANSITION__ITS_SRC_STATE:
				if (resolve) return getItsSrcState();
				return basicGetItsSrcState();
			case UISUTModelPackage.UI_TRANSITION__ITS_TRIGGER:
				return getItsTrigger();
			case UISUTModelPackage.UI_TRANSITION__ITS_CONDITION:
				return getItsCondition();
			case UISUTModelPackage.UI_TRANSITION__ITS_ACTION:
				return getItsAction();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case UISUTModelPackage.UI_TRANSITION__ITS_TRGT_STATE:
				setItsTrgtState((UIState)newValue);
				return;
			case UISUTModelPackage.UI_TRANSITION__ITS_SRC_STATE:
				setItsSrcState((UIState)newValue);
				return;
			case UISUTModelPackage.UI_TRANSITION__ITS_TRIGGER:
				setItsTrigger((UITrigger)newValue);
				return;
			case UISUTModelPackage.UI_TRANSITION__ITS_CONDITION:
				setItsCondition((UICondition)newValue);
				return;
			case UISUTModelPackage.UI_TRANSITION__ITS_ACTION:
				setItsAction((Action)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case UISUTModelPackage.UI_TRANSITION__ITS_TRGT_STATE:
				setItsTrgtState((UIState)null);
				return;
			case UISUTModelPackage.UI_TRANSITION__ITS_SRC_STATE:
				setItsSrcState((UIState)null);
				return;
			case UISUTModelPackage.UI_TRANSITION__ITS_TRIGGER:
				setItsTrigger((UITrigger)null);
				return;
			case UISUTModelPackage.UI_TRANSITION__ITS_CONDITION:
				setItsCondition((UICondition)null);
				return;
			case UISUTModelPackage.UI_TRANSITION__ITS_ACTION:
				setItsAction((Action)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case UISUTModelPackage.UI_TRANSITION__ITS_TRGT_STATE:
				return itsTrgtState != null;
			case UISUTModelPackage.UI_TRANSITION__ITS_SRC_STATE:
				return itsSrcState != null;
			case UISUTModelPackage.UI_TRANSITION__ITS_TRIGGER:
				return itsTrigger != null;
			case UISUTModelPackage.UI_TRANSITION__ITS_CONDITION:
				return itsCondition != null;
			case UISUTModelPackage.UI_TRANSITION__ITS_ACTION:
				return itsAction != null;
		}
		return super.eIsSet(featureID);
	}

} //UITransitionImpl
